<!--
 * @Author: 大辉 dbstt@qq.com
 * @Date: 2023-06-09 08:10:47
 * @LastEditors: 大辉 dbstt@qq.com
 * @LastEditTime: 2023-06-09 08:58:39
 * @FilePath: /blog/算法demo.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var removeElements = function (head, val) {
        for (let k = 0; k < head.length; k++) {
          if (head[k] === val) {
            head.splice(k, 1);
            k--;
          }
        }
        return head;
      };

      var removeElements = function (head, val) {
        let newListNode = ListNode(0, head);
        // newListNode =
        let cur = newListNode;
        while(cur && cur.next){
            if(cur.next.val === val){
                cur.next = cur.next.next;
            }else{
                cur = cur.next
            }
        }
        return newListNode.next;
      };
      console.log(removeElements([1, 2, 6, 3, 4, 5, 6], 6));
    </script>
  </body>
</html>
